In the event of technical difficulties with Szkopuł, please contact us via email at [email protected].
If you would like to talk about tasks, solutions or technical problems, please visit our Discord servers. They are moderated by the community, but members of the support team are also active there.
Euclid and Pythagoras are pseudonyms of two Byteotians for their love of mathematical puzzles. Lately, they spend evenings playing the following game. There is a stack of stones on the table. Friends perform alternating moves. Euclid's move consists of taking any positive multiple of stones from the stack (providing the stack contains at least stones) or adding exactly stones to the stack-adding the stones is possible, however, only in case the stack contains less than stones. Pythagoras' move is analogical, except that either he takes a multiple of stones, or adds exactly stones. The winner is the player who empties the stack. Euclid begins the game.
Friends wonder whether they have worked out this game perfectly. Help them and write a program that will state what should be the result of the game, providing both players are making optimal moves.
The first line of input contains one integer () denoting the number of test cases described in the following part of the input. Description of one test case consists of one line containing three integers , and ().
Output should include exactly lines containing answers to the subsequent test cases from input. The answer should be one letter E (if Euclid could bring about his victory, regardless of the Pythagoras' movements), P (if Pythagoras could bring about his victory, regardless of Euclid's moves) or R (for remis, i.e. draw in Polish, if the game will be played infinitely).
For the input data:
4 3 2 1 2 3 1 3 4 5 2 4 3
the correct result is:
P P E R
Explanation of the example: In the game from the first test case Euclid must add three stones to the stack in his move. Thanks to that Pythagoras can collect all 4 stones in his move and thus win.
Task author: Tomasz Idziaszek.
<Submit a solution> [0/1]